package com.xiaotu.spider.monitor;

import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.monitor.SpiderMonitor;
import us.codecraft.webmagic.monitor.SpiderStatus;

/**
 * @类名 MyStatusMXBean
 * @日期 2017年2月27日
 * @作者 高海军
 * @功能
 */
public class MyStatusMXBean extends SpiderStatus
{
	public MyStatusMXBean(Spider spider,
			SpiderMonitor.MonitorSpiderListener monitorSpiderListener)
	{
		super(spider, monitorSpiderListener);
	}
	
	@Override
	public int getPagePerSecond()
	{
		if (getStartTime() == null)
			return -1;
		int runSeconds = (int) (System.currentTimeMillis()
				- getStartTime().getTime()) / 1000;
		int succ = getSuccessPageCount();
		if (succ == 0)
			return -1;
		return runSeconds / getSuccessPageCount();
	}
	
	
}
